const sql = require("../../config/config");

// 获取goods
function getGoods(arr) {
  return sql("select * from goods_item where category = ?",arr);
}

// 获取goodsAll
function getGoodsAll() {
  return sql("select * from goods_item");
}

// 添加goods
function addGoods(arr) {
  return sql("insert into goods_item value (NULL,?,?,?,?,?,?,1,?)", arr);
}

// 更新goods
function updateGoods(arr) {
  return sql("update goods_item set title = ? , price = ? , src = ? , url = ? , category = ? , atime = ? where goods_id = ?", arr);
}

// 删除goods
function deleteGoods(arr) {
  return sql("delete from goods_item where goods_id = ?", arr);
}

// 是否展示goods
function showGoods(arr) {
  return sql("update goods_item set isShow = ? where goods_id = ?", arr);
}

// 批量删除
function batchDelete(arr) {
  return sql("delete from goods_item where goods_id in(?)",arr);
}

module.exports = {
  getGoods,
  getGoodsAll,
  addGoods,
  updateGoods,
  deleteGoods,
  showGoods,
  batchDelete
};
